package tests.pl.shenlon.ga;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import pl.shenlon.ga.Population;
import pl.shenlon.ga.SimpleSpecimen;
import pl.shenlon.ga.Specimen;

public class PopulationTest {
	@SuppressWarnings("rawtypes")
	private Population population;

	private final int populationSize = 100;
	@Before
	public void setUp() {
		population = new Population<SimpleSpecimen>(populationSize,
				SimpleSpecimen.class);
	}

	@SuppressWarnings("unchecked")
	@Test
	public void testConstructorForNotNullSpecimens() {
		for (Specimen specimen : population.getPopulation()) {
			Assert.assertNotNull(specimen);
		}

		Population<SimpleSpecimen> newPopulation = new Population<SimpleSpecimen>(
				population, 0.5);
		for (Specimen specimen : newPopulation.getPopulation()) {
			Assert.assertNotNull(specimen);
		}

		Population<SimpleSpecimen> newerPopulation = new Population<SimpleSpecimen>(
				population, 0.5, 2 * populationSize);
		for (Specimen specimen : newerPopulation.getPopulation()) {
			Assert.assertNotNull(specimen);
		}
	}
}